package com.lm.activiti.boot.recurrence;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;

/**
 * @author lm_jcf
 * @date 2020/9/27 17:38
 */
public class Recurrence {

    public static void main(String[] args) {
        List<DeptDto> deptDtoList = Lists.newArrayList();

    }

    private void selectDept(DeptDto deptDto, List<Integer> electDeptIdList, List<DeptDto> selectedDeptList) {

        if (CollectionUtils.isEmpty(electDeptIdList)) {
            return;
        } else {
            if (electDeptIdList.contains(deptDto.getDeptId())) {

                selectedDeptList.add(JSON.parseObject(JSON.toJSONString(deptDto), DeptDto.class));

                deptDto.setChildDeptDtoList(Lists.newArrayList());

                electDeptIdList.remove(deptDto.getDeptId());
            } else {
                // 查子
                if (CollectionUtils.isNotEmpty(deptDto.getChildDeptDtoList())) {
                    for (DeptDto dto : deptDto.getChildDeptDtoList()) {
                        selectDept(deptDto, electDeptIdList, selectedDeptList);
                    }
                }
                return;
            }
        }
    }
}
